//
//  WebViewProgressLine.swift
//  TianTianBiTing
//
//  Created by Gox mac 2 on 2019/3/6.
//  Copyright © 2019 Gox_WallyDiao. All rights reserved.
//

import UIKit

class WebViewProgressLine: UIView {

    /*
     // Only override draw() if you perform custom drawing.
     // An empty implementation adversely affects performance during animation.
     override func draw(_ rect: CGRect) {
     // Drawing code
     }
     */
    
    //  MARK: - ###### 产品寿命 ######
    init(frame:CGRect, lineColr:UIColor?) {
        super.init(frame: frame)
        self.backgroundColor = lineColr ?? UIColor.lightGray
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //  MARK: - ###### 子视图 ######
    
    //  MARK: - ###### 变量 ######
    
}

//  MARK: - ###### 变量 ######
//  MARK: - ###### 协议 ######
extension WebViewProgressLine{}

//  MARK: - ###### 事件处理 ######
//  MARK: - ###### 协议 ######
extension WebViewProgressLine{
    func startLoadingAnimation() {
        self.isHidden = false
        self.frame.size.width = 0.00
        weak var weakSelf = self
        UIView.animate(withDuration: 0.4, animations: {
            weakSelf?.frame.size.width = SCREEN_WIDTH * 0.6
        }) { (finished) in
            UIView.animate(withDuration: 0.4, animations: {
                weakSelf?.frame.size.width = SCREEN_WIDTH * 0.8
            }, completion: nil)
        }
    }
    func endLoadingAnimation() {
        weak var weakSelf = self
        UIView.animate(withDuration: 0.2, animations: {
            weakSelf?.frame.size.width = SCREEN_WIDTH
        }) { (finished) in
            weakSelf?.isHidden = true
        }
    }
}

//  MARK: - ###### 私有方法 ######
extension WebViewProgressLine{
    fileprivate func setupUI() {
        self.isHidden = true
    }
}

//  MARK: - ###### 公有方法 ######
extension WebViewProgressLine{
    
}
